﻿using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using NTTDATA.BEENChina.ResultCertification.Config;

namespace NTTDATA.BEENChina.ResultCertification.Checker.Date
{
    //[Serializable]
    [VerfityAttribute(Id = "VerfityRq0230", Name = "复合setC检证", CategoryType = EnumCategoryType.日期, Model = true)]
    public class VerfityRq0230 : VerfityOneResult
    {
        private bool empty = false;
        /// <summary>
        ///         
        /// </summary>
        [Category("第二三个日期是否同时有记载"), Description("true:同时无记载，false:同时有记载")]
        public bool Empty
        {
            get { return empty; }
            set { empty = value; }
        }

        public override bool CheckResult(List<List<string>> result, string entryCommon)
        {
            bool bresult = false;

            foreach (List<string> row in result)
            {
                if (row == null || row.Count() < 2)
                {
                    continue;
                }

                string secondDateStr = row.Count > 0 ? row[1] : string.Empty;
                string thirdDateStr = row.Count > 1 ? row[2] : string.Empty;

                secondDateStr = secondDateStr.Replace("/", string.Empty);
                thirdDateStr = thirdDateStr.Replace("/", string.Empty);

                bresult = Empty ?
                    string.IsNullOrEmpty(secondDateStr) && string.IsNullOrEmpty(thirdDateStr) :
                    !string.IsNullOrEmpty(secondDateStr) && !string.IsNullOrEmpty(thirdDateStr);
                                        
                if (bresult)
                {
                    break;
                }
            }

            if (bresult)
            {
                System.Console.WriteLine("VerfityRQ0230");
                System.Console.WriteLine(Name);
            }

            return bresult;
        }
    }
}
